#include <iostream>
#include <vector>
using namespace std;
class Graph_Travel{
public:
    int num;
    int *adj;
    bool *visited;
public:
    Graph_Travel();
    ~Graph_Travel();
    void DFS(int r,int col);
    void show();
};
Graph_Travel::Graph_Travel() {
    cin>>num;
    adj = new int[num*num];
    visited = new bool[num*num];
    for(int i=0;i<num-1;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[(a-1)*num+b-1] = 1;
        adj[(b-1)*num+a-1] = 1;
    }
}
Graph_Travel::~Graph_Travel() {
    delete [] adj;
    delete [] visited;
}
void Graph_Travel::show() {
    int count=0;
    for(int i=0;i<num;i++)
    {
        for(int j=0;j<num;j++)
        {
//            cout<<"count: "<<count<<"\n";
            cout<<adj[i*num+j]<<" ";
            count++;
        }
        cout<<"\n";
    }
    cout<<"生成"<<count<<"个数"<<endl;

}
void Graph_Travel::DFS(int r, int col) {
    visited[r*num+col] = true;

}
int main()
{
    Graph_Travel g = Graph_Travel();
    g.show();
}
